//
//  ViewController.m
//  CarSalesMS_GCX
//
//  Created by Tony on 2016/10/21.
//  Copyright © 2016年 Tony. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.view.backgroundColor = [UIColor yellowColor];
    
    [self myloadData];
}

- (void)myloadData {
    
    NSMutableArray<NSDictionary *> * bigArr = [NSMutableArray array];
    // big
    for (int i = 0; i < 2; i++) {
        
        NSMutableArray<NSDictionary *> *smallArr = [NSMutableArray array];
        // small
        for (int j = 0; j < 3; j++) {
            
            NSMutableArray<NSDictionary *> * commArr = [NSMutableArray array];
            // comm
            for (int k = 0; k < 5; k++) {
                NSDictionary * commDict = @{@"commName": [NSString stringWithFormat:@"%d-%d-%d", i, j, k],
                                            @"commCount": @(k)};
                [commArr addObject:commDict];
            } // for comm end
            
            NSDictionary * smallDict = @{@"smallName": [NSString stringWithFormat:@"%d-%d", i, j],
                                         @"commArr": commArr};
            [smallArr addObject:smallDict];
        } // for small end
        
        NSDictionary * bigDict = @{@"bigName": [NSString stringWithFormat:@"-%d", i],
                                   @"smallArr": smallArr};
        [bigArr addObject:bigDict];

    } // for big end
    
    // 将bigArr写入plist
    NSString * path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString * filePath = [path stringByAppendingPathComponent:@"commodity.plist"];
    if ([bigArr writeToFile:filePath atomically:YES]) {
        NSLog(@"%@", filePath);
    }
    
}








@end
